home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 12, No. 01 (1991-01)(MindCraft Publishing)(Side A)[a].zip
/
Nibble Volume 12, No. 01 (1991-01)(MindCraft Publishing)(Side A)[a].po
/
PACK.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
5KB
|
126 lines
*--------------------------------*
* Super Res_PACKBYTES format *
* picture packer by Peter Stubbs *
*--------------------------------*
* MERLIN 816 ASSEMBLER *
*--------------------------------*
* Copyright (C) 1991 *
* Mindcraft Publ. Corp. *
*--------------------------------*
* PLEASE NOTE:
* -----------
* 1. Program is relocatable & runs at any address
*
* 2. The picture to be packed must already be in
* the Super Res screen buffer ($E12000-$E19FFF)
*
* 3. The packed pic is saved at $1400 in bank 00
LINSAVE EQU $3 ;To hold value at NEWVIDEO
SIZEPTR EQU $4 ;Size of SuperRes pic
STARTPTR EQU $7 ;Ptr to start of pic
PROMPT EQU $33 ;Current screen prompt
BUFFSIZE EQU $EB ;Size of data to pack
NUMBYTES EQU $ED ;Number of bytes packed
PTR EQU $FC ;For indexed indirect mode
ERRCODE EQU $FE ;Pack error if non zero
NEWVIDEO EQU $C029
COUT EQU $FDED ;ROM Character output
PRNTAX EQU $F941 ;ROM Hex print
SIZE EQU $9400-$1400 ;Max size of packed pic
BUFFADR EQU $001400 ;Output buffer=$1400 bank 00
ORG $300
TR ADR
PAK LDA NEWVIDEO
STA LINSAVE ;Save for later
ORA #%01000000 ;Linear mode on, but not
STA NEWVIDEO ; Super res mode
CLC ;Prepare to enter CPU
XCE ; native mode with
REP #$30 ; full 16 bit registers
MX %00 ;Tell Merlin
* SETUP VALUES TO PACK PICTURE DATA
LDA #$A000-$2000 ;Size of pic & pal data
STA SIZEPTR
LDA #<$E12000 ;Start of pic data
STA STARTPTR
LDA #^$E12000
STA STARTPTR+2
* Code to pack the specified data range
PEA $0000 ;Space for result
PEA #^STARTPTR ;Pointer to word with start
PEA #<STARTPTR ; of area to pack
PEA #^SIZEPTR ;Pointer to word with size
PEA #<SIZEPTR ; of area to pack
PEA #^BUFFADR ;Address of output buffer
PEA #<BUFFADR ; ($1400 in bank 00)
PEA #<SIZE ;Size of output buffer
LDX #$2603 ;_PackBytes Tool call
JSL $E10000 ;Call the Tool locator
PLA ;Get no. of bytes packed
STA NUMBYTES ;No of bytes packed
LDA STARTPTR ;Is all of picture packed?
CMP #<$E1A000 ;Result checked later
PHP ;Save result of compare
SEC ;Emulation mode back on
XCE
MX %11
LDA LINSAVE ;Restore video state
STA NEWVIDEO
STZ ERRCODE ;Start with error code 0
PLP ;Get result of compare back
BEQ NOERR ;If were equal then all done
INC ERRCODE ;Else flag a packing error
* Determine how to display results
NOERR LDA PROMPT ;Get current screen prompt
CMP #"]" ;Applesoft?
BEQ PRINTIT ;If yes display on screen
CMP #"*" ;Monitor?
BNE EXIT2 ;No, we came from another
; program so don't display
* Display results on screen for user
PRINTIT LDX #$0 ;So we use PTR as our index
LDA ERRCODE ;Get error code
BEQ OK ;If no pack error, else
PER ERR ; push text loc. onto stack
PLA ;Get low byte
STA PTR ; and set up PTR index
PLA ;Get high byte
STA PTR+1 ; and set up rest of index
ELOOP LDA (PTR,X) ;Get character to display
BEQ EXIT2 ;If 00 then at end of text
JSR COUT ; else print it
INC PTR ;Point at next char of text
BRA ELOOP ;ALWAYS (gets next character)
OK PER MSG ;Push loc. of BSAVE message
PLA ; then get low byte from stack
STA PTR ; and set up PTR index
PLA ;Get high byte
STA PTR+1 ; and set up rest of index
MLOOP LDA (PTR,X) ;print BSAVE details
BEQ EXIT ;If 00 then at end of text
JSR COUT ; else print it
INC PTR ;Point at next char of text
BRA MLOOP ;ALWAYS
EXIT LDA NUMBYTES+1 ;Use ROM PRNTAX routine
LDX NUMBYTES ; to print L$ value
JSR PRNTAX
EXIT2 RTS ;Return to caller
MSG ASC "BSAVE(Filename),A$1400,L$"
HEX 00
ERR ASC "Pack err"
HEX 8700
lst off